package org.budo.alipay.api;

import org.budo.support.lang.util.StringUtil;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

import lombok.Getter;
import lombok.Setter;

/**
 * @author limingwei
 */
@Getter
@Setter
public class AbstractAliPayApi implements AliPayApi {
    private String serverUrl = "https://openapi.alipay.com/gateway.do";

    private String appId;

    private String privateKey;

    protected AlipayClient alipayClient() {
        if (StringUtil.isNullOrEmpty(this.getPrivateKey())) {
            throw new IllegalArgumentException("#25 privateKey is null, this=" + this);
        }

        return new DefaultAlipayClient(this.getServerUrl(), this.getAppId(), this.getPrivateKey());
    }
}